/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.informatica.facades;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import py.una.informatica.entidades.Generos;

/**
 *
 * @author MARTINCHO
 */
@Stateless
public class GenerosFacade extends AbstractFacade<Generos> {
    @PersistenceContext(unitName = "py.com.konecta_EmergenciasEJB_ejb_1.0-SNAPSHOTPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public GenerosFacade() {
        super(Generos.class);
    }
    
    public Generos getGeneroById(Long idGenero) {
        Generos g = null;
        try {
            getEntityManager().getEntityManagerFactory().getCache().evictAll();
            TypedQuery<Generos> query = getEntityManager().createNamedQuery("Generos.findByIdGenero", Generos.class);
            g = query.setParameter("idGenero", idGenero).getSingleResult();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return g;
    }
    
}
